package com.shm.alibaba;

import java.util.Scanner;

public class Main2 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        String s = input.nextLine();
        int t = Integer.parseInt(s);
        for (int j = 0; j < t; j++) {
            String str = input.nextLine();
            String[] ss = str.split(" ");
            int a=Integer.parseInt(ss[0]);
            int b=Integer.parseInt(ss[1]);
            int n=Integer.parseInt(ss[2]);
            if (n==2){
                System.out.println(a*a-2*b);
            }
        }
    }
}
